/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ma.projet.entities;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Maison
 */
@Entity
@Table(name = "incident")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Incident.findAll", query = "SELECT i FROM Incident i"),
    @NamedQuery(name = "Incident.findByWeekSous", query = "SELECT i FROM Incident i WHERE i.debutIncident>=:debut and i.debutIncident<:fin and i.soustraitantID.soustraitantID=:sous"),
    @NamedQuery(name = "Incident.findByNincident", query = "SELECT i FROM Incident i WHERE i.nincident = :nincident"),
    @NamedQuery(name = "Incident.findByStatutID", query = "SELECT i FROM Incident i WHERE i.statutID = :statutID"),
    @NamedQuery(name = "Incident.findByWeek", query = "SELECT i FROM Incident i WHERE i.debutIncident>=:debut and i.debutIncident<:fin"),
    @NamedQuery(name = "Incident.findBySousreseauID", query = "SELECT i FROM Incident i WHERE i.sousreseauID = :sousreseauID"),
    @NamedQuery(name = "Incident.findByDescription", query = "SELECT i FROM Incident i WHERE i.description = :description"),
    @NamedQuery(name = "Incident.findByDebutIncident", query = "SELECT i FROM Incident i WHERE i.debutIncident > :debutIncident and i.debutIncident<= :f"),
    @NamedQuery(name = "Incident.findByFinIncident", query = "SELECT i FROM Incident i WHERE i.finIncident = :finIncident"),
    @NamedQuery(name = "Incident.findByTypeimpact", query = "SELECT i FROM Incident i WHERE i.typeimpact = :typeimpact"),
    //@NamedQuery(name = "Incident.findByDebutImpact", query = "SELECT i FROM Incident i WHERE i.debutImpact = :debutImpact")
})
public class Incident implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "nincident")
    private Long nincident;
    @Column(name = "statutID")
    private BigInteger statutID;
    @Column(name = "sousreseauID")
    private BigInteger sousreseauID;
    @Size(max = 254)
    @Column(name = "description")
    private String description;
    @Column(name = "debutIncident")
    @Temporal(TemporalType.TIMESTAMP)
    private Date debutIncident;
    @Column(name = "finIncident")
    @Temporal(TemporalType.TIMESTAMP)
    private Date finIncident;
    @Column(name = "typeimpact")
    private Integer typeimpact;
//    @Column(name = "debutImpact")
//    private Integer debutImpact;
    @JoinColumn(name = "mobilisationID", referencedColumnName = "mobilisationID")
    @ManyToOne
    private Mobilisation mobilisationID;
    @JoinColumn(name = "siteID", referencedColumnName = "siteID")
    @ManyToOne
    private Site siteID;
    @JoinColumn(name = "soustraitantID", referencedColumnName = "soustraitantID")
    @ManyToOne
    private Soustraitant soustraitantID;

    public Incident() {
    }

    public Incident(Long nincident) {
        this.nincident = nincident;
    }

    public Long getNincident() {
        return nincident;
    }

    public void setNincident(Long nincident) {
        this.nincident = nincident;
    }

    public BigInteger getStatutID() {
        return statutID;
    }

    public void setStatutID(BigInteger statutID) {
        this.statutID = statutID;
    }

    public BigInteger getSousreseauID() {
        return sousreseauID;
    }

    public void setSousreseauID(BigInteger sousreseauID) {
        this.sousreseauID = sousreseauID;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getDebutIncident() {
        return debutIncident;
    }

    public void setDebutIncident(Date debutIncident) {
        this.debutIncident = debutIncident;
    }

    public Date getFinIncident() {
        return finIncident;
    }

    public void setFinIncident(Date finIncident) {
        this.finIncident = finIncident;
    }

    public Integer getTypeimpact() {
        return typeimpact;
    }

    public void setTypeimpact(Integer typeimpact) {
        this.typeimpact = typeimpact;
    }

//    public Integer getDebutImpact() {
//        return debutImpact;
//    }
//
//    public void setDebutImpact(Integer debutImpact) {
//        this.debutImpact = debutImpact;
//    }

    public Mobilisation getMobilisationID() {
        return mobilisationID;
    }

    public void setMobilisationID(Mobilisation mobilisationID) {
        this.mobilisationID = mobilisationID;
    }

    public Site getSiteID() {
        return siteID;
    }

    public void setSiteID(Site siteID) {
        this.siteID = siteID;
    }

    public Soustraitant getSoustraitantID() {
        return soustraitantID;
    }

    public void setSoustraitantID(Soustraitant soustraitantID) {
        this.soustraitantID = soustraitantID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nincident != null ? nincident.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Incident)) {
            return false;
        }
        Incident other = (Incident) object;
        if ((this.nincident == null && other.nincident != null) || (this.nincident != null && !this.nincident.equals(other.nincident))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ma.projet.entities.Incident[ nincident=" + nincident + " ]";
    }
    
}
